package com.hellobike.haxing.modules.order.send;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 售后成功向C端Mq扣除佣金统计
 */
@Component
@Data
@Slf4j
public class OrderAfterSuccessCSend {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    /**
     * 售后成功向C端Mq扣除佣金统计
     * @param id 售后ID
     */
    public void sendOrderAfterSuccess(Long id) {
        rocketMQTemplate.asyncSend("after-order-backend-success-topic", id, new SendCallback() {
            @Override
            public void onSuccess(SendResult sendResult) {
                log.info("==after-order-backend-success-topic=success===afterId=>{}",id);
            }

            @Override
            public void onException(Throwable e) {
                log.error("==after-order-backend-success-topic==error==>", e);
            }
        });
    }
}
